//send clientside files.
AddCSLuaFile("shared.lua")
AddCSLuaFile("cl_init.lua")
AddCSLuaFile("client/cl_util.lua")
AddCSLuaFile("client/cl_hints.lua")
AddCSLuaFile("client/cl_hud.lua")
AddCSLuaFile("client/cl_deaths.lua")
AddCSLuaFile("client/cl_msg.lua")
AddCSLuaFile("client/cl_entity.lua")
AddCSLuaFile("client/cl_scoreboard.lua")
AddCSLuaFile("client/cl_helpvgui.lua")
AddCSLuaFile("client/cl_menu.lua")
AddCSLuaFile("client/cl_spawnmenu.lua")
AddCSLuaFile("client/cl_chat.lua")
AddCSLuaFile("client/cl_inventory.lua")
AddCSLuaFile("admin/cl_admin.lua")
AddCSLuaFile("admin/ersmodule.lua")

//include serverside files.
include("shared.lua")
include("player.lua")
include("money.lua")
include("chat.lua")
include("rpdm_functions.lua")
include("bannedprops.lua")
include("buy.lua")
include("propprotect.lua")
include("stats.lua")
include("inventory.lua")
include("chatcommand.lua")
include("admin/admin.lua")

//add everything in the content folder to be sent to clients.
local path = "../"..GM.Folder.."/content"
local folders = {""}
while true do
	local curdir = table.remove(folders,1)
	if not curdir then break end
	local searchdir = path..curdir
	for _, filename in ipairs(file.Find(searchdir.."/*")) do
		if filename ~= ".svn" then
			if file.IsDir(searchdir.."/"..filename) then
				table.insert(folders,curdir.."/"..filename)
			else
				resource.AddSingleFile(string.sub(curdir.."/"..filename,2))
			end
		end
	end
end

//make breakable glass unbreakable.
function HardenGlass()
	local filtr = ents.Create("filter_activator_name")
	if (not IsValid(filtr)) then
		error"Damage filter is not valid!"
	end
	filtr:SetKeyValue("targetname","nobreak")
	filtr:SetKeyValue("negated","1")
	filtr:Spawn()
	for _,ent in ipairs(ents.FindByClass("func_breakable_surf")) do
		ent:Fire("setdamagefilter", "nobreak", 0)
		local physobj = ent:GetPhysicsObject()
		if physobj:IsValid() then physobj:SetMass(50000) end
	end
end
hook.Add("InitPostEntity", "HardenGlass", HardenGlass)

//unlock doors.
function UnlockDoors()
	for _,ent in ipairs(ents.FindByClass("prop_door_rotating")) do
			ent.Entity:Fire("unlock", "", 0)
	end	
	for _,ent in ipairs(ents.FindByClass("func_door")) do
			ent.Entity:Fire("unlock", "", 0)
	end	
end
hook.Add("InitPostEntity", "UnlockDoors", UnlockDoors)